﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;
using Bot.Domain.Specifications;

namespace Bot.Domain.Categories.Service
{
    public class SmartTriggerActionSelectedVisitorSegmentDomainService : ISmartTriggerActionSelectedVisitorSegmentDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, SmartTriggerActionSelectedVisitorSegment> _repository;

        public SmartTriggerActionSelectedVisitorSegmentDomainService(IRepository<Guid, SmartTriggerActionSelectedVisitorSegment> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public SmartTriggerActionSelectedVisitorSegment Create(SmartTriggerActionSelectedVisitorSegment category)
        {
            return _repository.Create(category);
        }

        public SmartTriggerActionSelectedVisitorSegment Get(Guid id)
        {
            return _repository.Get(id);
        }

        public SmartTriggerActionSelectedVisitorSegment Update(SmartTriggerActionSelectedVisitorSegmentUpdateBo bo)
        {
            SmartTriggerActionSelectedVisitorSegment smartTriggerActionSelectedVisitorSegment = _repository.Get(bo.Id);
            smartTriggerActionSelectedVisitorSegment.Id = bo.Id;
            smartTriggerActionSelectedVisitorSegment.SmartTriggerActionId = bo.SmartTriggerActionId;
            smartTriggerActionSelectedVisitorSegment.VisitorSegmentId = bo.VisitorSegmentId;

            _repository.Update(smartTriggerActionSelectedVisitorSegment);

            return smartTriggerActionSelectedVisitorSegment;

        }

        public IEnumerable<SmartTriggerActionSelectedVisitorSegment> List()
        {
            return _repository.ListAll();
        }
        public IEnumerable<SmartTriggerActionSelectedVisitorSegment> GetByActionId(Guid actionId)
        {
            return _repository.List(new SmartTriggerActionSelectedSegmentFilterSpecification(actionId));
        }
        public void Delete(Guid id)
        {
            SmartTriggerActionSelectedVisitorSegment smartTriggerActionSelectedVisitorSegment = _repository.Get(id);

            _repository.Delete(smartTriggerActionSelectedVisitorSegment);

        }
    }
}
